package com.gaohe.official.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.log.annotation.Log;
import com.gaohe.common.log.enums.BusinessType;
import com.gaohe.common.security.annotation.RequiresPermissions;
import com.gaohe.official.domain.FmCommunitySchool;
import com.gaohe.official.service.IFmCommunitySchoolService;
import com.gaohe.common.core.web.controller.BaseController;
import com.gaohe.common.core.web.domain.AjaxResult;
import com.gaohe.common.core.utils.poi.ExcelUtil;
import com.gaohe.common.core.web.page.TableDataInfo;

/**
 * 圈子校区Controller
 * 
 * @author ruoyi
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/school")
public class FmCommunitySchoolController extends BaseController
{
    @Autowired
    private IFmCommunitySchoolService fmCommunitySchoolService;

    /**
     * 查询圈子校区列表
     */
    @RequiresPermissions("official:school:list")
    @GetMapping("/list")
    public TableDataInfo list(FmCommunitySchool fmCommunitySchool)
    {
        startPage();
        List<FmCommunitySchool> list = fmCommunitySchoolService.selectFmCommunitySchoolList(fmCommunitySchool);
        return getDataTable(list);
    }

    /**
     * 导出圈子校区列表
     */
    @RequiresPermissions("official:school:export")
    @Log(title = "圈子校区", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FmCommunitySchool fmCommunitySchool)
    {
        List<FmCommunitySchool> list = fmCommunitySchoolService.selectFmCommunitySchoolList(fmCommunitySchool);
        ExcelUtil<FmCommunitySchool> util = new ExcelUtil<FmCommunitySchool>(FmCommunitySchool.class);
        util.exportExcel(response, list, "圈子校区数据");
    }

    /**
     * 获取圈子校区详细信息
     */
    @RequiresPermissions("official:school:query")
    @GetMapping(value = "/{communitySchoolId}")
    public AjaxResult getInfo(@PathVariable("communitySchoolId") Long communitySchoolId)
    {
        return success(fmCommunitySchoolService.selectFmCommunitySchoolByCommunitySchoolId(communitySchoolId));
    }

    /**
     * 新增圈子校区
     */
    @RequiresPermissions("official:school:add")
    @Log(title = "圈子校区", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FmCommunitySchool fmCommunitySchool)
    {
        return toAjax(fmCommunitySchoolService.insertFmCommunitySchool(fmCommunitySchool));
    }

    /**
     * 修改圈子校区
     */
    @RequiresPermissions("official:school:edit")
    @Log(title = "圈子校区", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FmCommunitySchool fmCommunitySchool)
    {
        return toAjax(fmCommunitySchoolService.updateFmCommunitySchool(fmCommunitySchool));
    }

    /**
     * 删除圈子校区
     */
    @RequiresPermissions("official:school:remove")
    @Log(title = "圈子校区", businessType = BusinessType.DELETE)
	@DeleteMapping("/{communitySchoolIds}")
    public AjaxResult remove(@PathVariable Long[] communitySchoolIds)
    {
        return toAjax(fmCommunitySchoolService.deleteFmCommunitySchoolByCommunitySchoolIds(communitySchoolIds));
    }
}
